/**
 * Created by Administrator on 2015/12/3.
 */
"use strict";
var F = require('../../../common/function');
var order_F = require('./order_common');
var _o2oServiceApi = require('../../../common/o2oServiceApi');
var o2oServiceApi = new _o2oServiceApi;
var _ = require('underscore');
/**
 * 获取商家的订单详情
 * @param queryObj
 */
exports.order_detail = function *(queryObj){
    queryObj.act =1;
    queryObj.orderid  =queryObj.id;
    delete queryObj.id;
    let orderResult = yield o2oServiceApi.post('order','detail',1,queryObj);
    if(orderResult.status == 400 || orderResult['result']['error']==1 || _.isEmpty(orderResult['result'])){
        return F.returnMsg(300, orderResult['message']['msg'], 1);
    }else{
        yield order_F.getPayment(orderResult); //处理支付金额
        let result =[];
        result.push(orderResult['result']);
        orderResult['result']=result;
        yield   order_F.addUserInfo(orderResult);
        return F.returnMsg(200, '查找成功', 1, orderResult['result'][0]);
    }
}

